﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class ZBZLDetail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["userName"] == null || Session["roleID"] == null)
        {
            Response.Redirect("Login.aspx");
            Response.End();
        }
        if (!Page.IsPostBack)
        {            
            string DataID = Request.QueryString["AutoId"].ToString();
            string DataYear = Request.QueryString["dataYear"].ToString();
            GetDataMessageAndBind(DataID,DataYear);
            //BindAttachFiles(DataID);
            string userName = Session["userName"].ToString();
            string roleID = Session["roleID"].ToString();            
        }

    }
    //获取并绑定数据
    protected void GetDataMessageAndBind(string DataID,string DataYear)
    {
        string tabYear = DataYear;
        string tabName = "ZBZL" + tabYear;
        string sqlString = "select * From " + tabName + " where AUTOID='" + DataID + "'";
        DBOperation DBO = new DBOperation();
        SqlDataReader sdr = DBO.GetDataReader(sqlString);
        
        
        if (sdr.Read())
        {
            lblDataID.Text =DataYear + sdr["AUTOID"].ToString();            
            lblTitle.Text = sdr["TITLE"].ToString();            
            lblWriteDate.Text = Convert.ToDateTime(sdr["WRITEDATE"].ToString()).ToShortDateString();
            lblUpUser.Text = BasicClass.GetTrueNameByUserName(sdr["USERNAME"].ToString());
            lblBrief.Text = sdr["BRIEF"].ToString();
            string FilesPath = sdr["FILESPATH"].ToString();
            string encodeFilePath = Server.UrlEncode(FilesPath);
            lblFiles.Text = "<img src='images/filePic.gif' /><a href='DownLoad.aspx?filepath=" + encodeFilePath + "' target='blank'>" + FilesPath.Substring(FilesPath.LastIndexOf("\\") + 1) + "</a>";            
        }
        sdr.Close();
    }
}
